package com.ruoyi.web.group.playerscores.controller;

;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.group.playerscores.entity.PlayerScores;
import com.ruoyi.web.group.playerscores.service.PlayerScoresService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * 比赛详细得分控制器
 */
@RestController
@RequestMapping("/player/scores")
public class PlayerScoresController {

    @Autowired
    private PlayerScoresService playerScoresService;

    /**
     * 添加比赛详细数据
     * @param playerScores
     * @return
     */
    @PostMapping("add")
    public AjaxResult add(@RequestBody PlayerScores playerScores){
        if(playerScores != null ){
            playerScores.setCreatedAt(new Date());
            if(playerScoresService.save(playerScores)){
                return AjaxResult.success("操作成功");
            }
        }
        return AjaxResult.error("操作失败");
    }

    /**
     * 比赛详细信息
     * @param matchId
     * @return
     */
    @GetMapping("/findList")
    public AjaxResult findList(@RequestParam Integer matchId ){
        return AjaxResult.success(playerScoresService.findList(matchId));
    }
}